package java_learn.java_jinjie.GenericClass;

import java.util.ArrayList;
import java.util.Collections;

/**
 * 准备牌/洗牌/发牌/看牌
 */
public class Doudizhu {
    public static void main(String[] args) {
        //1.准备牌
        //定义一个存储54张牌的ArrayList集合
        ArrayList<String> poker = new ArrayList<>();
        //定义两个数组，一个数组存储牌花色，一个存储牌序号
        String[] colors = {"♥️", "♣️", "♠️", "♦️"};
        String[] numbers = {"2", "A", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        poker.add("大王");
        poker.add("小王");
        //循环嵌套遍历
        for (String number : numbers) {
            for (String color : colors) {
                poker.add(color + number);
            }
        }
//        System.out.println(poker);
        //2.洗牌
        Collections.shuffle(poker);
//        System.out.println(poker);
        //3.发牌
        //定义四个集合，存储玩家的牌和底牌
        ArrayList<String> player01 = new ArrayList<>();
        ArrayList<String> player02 = new ArrayList<>();
        ArrayList<String> player03 = new ArrayList<>();
        ArrayList<String> diPai = new ArrayList<>();
        /*
        遍历扑克集合，获取每一张牌
        %3给三个玩家轮流发牌
         */
        for (int i = 0; i < poker.size(); i++) {
            //获取每一张
            String p = poker.get(i);
            //轮流发牌
            if (i >= 51) {
                //底牌发牌
                diPai.add(p);
            } else if (i % 3 == 0) {
                player01.add(p);
            } else if (i % 3 == 1) {
                player02.add(p);
            } else if (i % 3 == 2) {
                player03.add(p);
            }
        }
        System.out.println(player01);
        System.out.println(player02);
        System.out.println(player03);
        System.out.println(diPai);
    }

}
